package mess;

import java.util.ArrayList;
import java.util.List;

public class LeeCode_face_05_02 {
    public static void main(String[] args) {
        System.out.println(printBin(0.625));
        List<Integer> list = new ArrayList<>();
    }
    private static String printBin(double num) {
        StringBuilder sb = new StringBuilder("0.");
        double remain = num;
        double temp = 1;
        int count = 0;
        while(remain > 0){
            System.out.println(sb.toString());
            if(count > 32){
                return "ERROR";
            }
            temp /= 2;
            if(remain >= temp){
                remain -= temp;
                sb.append("1");
            }else{
                sb.append("0");
            }
            count++;
        }
        return sb.toString();
    }
}
